commonlibsse_ng\re\h/
hkReferencedObject.rs1use core::sync::atomic::{AtomicI16, Ordering};
2
3use crate::re::hkBaseObject::hkBaseObject;
4use crate::re::offsets_rtti::RTTI_hkReferencedObject;
5use crate::re::offsets_vtable::VTABLE_hkReferencedObject;
6use crate::re::{hkClass, hkStatisticsCollector};
7use crate::rel::id::VariantID;
8
9#[repr(C)]
13#[derive(Debug)]
14pub struct hkReferencedObject {
15 pub __base: hkBaseObject,
17
18 pub memSizeAndFlags: u16,
21
22 pub referenceCount: AtomicI16,
25
26 pub pad0C: u32,
29}
30
31const _: () = {
33 assert!(core::mem::offset_of!(hkReferencedObject, __base) == 0x0);
34 assert!(core::mem::offset_of!(hkReferencedObject, memSizeAndFlags) == 0x08);
35 assert!(core::mem::offset_of!(hkReferencedObject, referenceCount) == 0x0A);
36 assert!(core::mem::offset_of!(hkReferencedObject, pad0C) == 0x0C);
37 assert!(core::mem::size_of::<hkReferencedObject>() == 0x10);
38};
39
40impl crate::re::hkRefPtr::hkRefPtrCounted for hkReferencedObject {}
41
42#[commonlibsse_ng_derive_internal::to_bitflags]
44#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
45#[repr(u32)]
46pub enum LockMode {
47 None = 0,
48 Auto = 1,
49 Manual = 2,
50}
51
52impl hkReferencedObject {
53 pub const RTTI: VariantID = RTTI_hkReferencedObject;
55
56 pub const VTABLE: [VariantID; 1] = VTABLE_hkReferencedObject;
58
59 pub const MEM_SIZE: u16 = 0x7FFF;
61
62 #[inline]
64 pub const fn new() -> Self {
65 Self {
66 __base: hkBaseObject::new(),
67 memSizeAndFlags: Self::MEM_SIZE,
68 referenceCount: AtomicI16::new(1), pad0C: 0,
70 }
71 }
72
73 #[commonlibsse_ng_derive_internal::relocate_fn(se_id = 56606, ae_id = 57010)]
75 #[inline]
76 pub fn add_reference(&self) {}
77
78 #[commonlibsse_ng_derive_internal::relocate_fn(se_id = 56607, ae_id = 57011)]
80 #[inline]
81 pub fn remove_reference(&self) {}
82
83 #[inline]
85 pub fn get_reference_count(&self) -> i16 {
86 self.referenceCount.load(Ordering::Acquire)
87 }
88
89 #[inline]
91 pub const fn get_allocated_size(&self) -> i32 {
92 (self.memSizeAndFlags & Self::MEM_SIZE) as i32
93 }
94}
95
96#[repr(C)]
98pub struct hkReferencedObjectVtbl {
99 pub CxxDrop: fn(this: &mut hkReferencedObject),
101
102 pub GetClassType: fn(this: &hkReferencedObject) -> Option<*const hkClass>,
104
105 pub CalcContentStatistics:
107 fn(this: &hkReferencedObject, collector: &mut hkStatisticsCollector, cls: Option<&hkClass>),
108}
109
110impl Default for hkReferencedObjectVtbl {
111 #[inline]
112 fn default() -> Self {
113 Self::new()
114 }
115}
116
117impl hkReferencedObjectVtbl {
118 #[inline]
120 pub const fn new() -> Self {
121 const fn CxxDrop(_this: &mut hkReferencedObject) {}
122
123 const fn GetClassType(_this: &hkReferencedObject) -> Option<*const hkClass> {
124 None
125 }
126
127 const fn CalcContentStatistics(
128 _this: &hkReferencedObject,
129 _collector: &mut hkStatisticsCollector,
130 _cls: Option<&hkClass>,
131 ) {
132 }
133
134 Self { CxxDrop, GetClassType, CalcContentStatistics }
135 }
136}
137
138impl Default for hkReferencedObject {
139 #[inline]
140 fn default() -> Self {
141 Self::new()
142 }
143}